<style type="text/css">
    .select {
        height: 38px;
        line-height: 38px;
        line-height: 36px\9;
        border: 1px solid #e6e6e6;
        background-color: #fff;
        border-radius: 2px;
        font-size: 12px;
    }
</style>
<div class="layui-form-item" id="stock">
    <label class="layui-form-label">材料：</label>
    <div class="layui-input-inline" style="width: 100px;">
        <select name="cate_id" class="select"  style="display: block;" onchange="ajaxStock(this)">
            <option value="0">请选择分类</option>
            <foreach name="cate" item="v" key="k">
                <option value="{$v.id}">{$v.cate_name}</option>
            </foreach>
        </select>
    </div>

    <div class="layui-input-inline stocklist" style="width: 100px; display: none;">
        
    </div>

    <div class="layui-input-inline" style="width: 100px;">
        <input type="text" name="num" placeholder="数量" autocomplete="off" class="layui-input" lay-verify="数量">
    </div>
    <div class="layui-form-mid layui-word-aux">
        <span class="layui-badge" onclick="removeStock(this)">×</span>
    </div>
</div>
<script type="text/javascript">

    $(function () {
        ajaxStock = function (obj) {
           
            $.get("{:U('Food/ajaxStockList')}", {cate_id: $(obj).val()}, function (data) {
                console.log($(this));
                $(obj).parent().next().html(data).show();

            }, 'text');
        };

       
           // $.get("{:U('Food/ajaxStockList')}", {cate_id: $(this).val()}, function (data) {
           //     $(".stocklist").show();
           //     $(data).appendTo(".stocklist");
           // }, 'text');
       
    
   });   
</script>

